<template>
  <div id="Card">
    <div class="titleBox">
      <div class="title">
        我的卡券
      </div>
    </div>
    <div class="cardBox">
      <div class="header">
        <div
          v-for="(item, index) in statuList"
          :key="item.status"
          class="title"
          :class="{ active: tabIndex == index }"
          @click="selectedIndex(item, index)"
        >
          {{ item.title }}
        </div>
      </div>
    </div>
    <CardList
      ref="Search"
      :status="TabStatus"
    />
  </div>
</template>

<script>
import CardList from "../../components/Assets/list.vue";

export default {
  name: 'Card',
  components: {
    CardList,
    // PageNation,
  },
  data() {
    return {
      tabIndex: 0,
      TabStatus: 0,
      statuList: [ // 0:UNUSED(“未使用”) 2:USED(“已使用”) 3:OBSOLETE(“已作废”)
        {
          status: 0,
          title: "未使用",
          statusName: "UNUSED",
        },
        {
          status: 2,
          title: "已使用",
          statusName: "USED",
        },
        {
          status: 3,
          title: "已作废",
          statusName: "OBSOLETE",
        },
      ],
    }
  },
  /* HTML DOM加载后马上执行的，如赋值*/
  computed: {},

  /* 观察Vue实例上的数据变动 */
  watch: {},

  /* 模板渲染成html前调用，即通常初始化某些属性值，然后再渲染成视图 */
  created() {},

  /* 模板渲染成html后调用，通常是初始化页面完成后，再对html的dom节点进行一些需要的操作 */
  mounted() {
  },

  /* methods则必须要有一定的触发条件才能执行 */
  methods: {
    //选择状态
    selectedIndex(item, index) {
      console.log('选择状态',item, index)
      this.tabIndex = index
      this.TabStatus = item.status
    },
  }
}
</script>

<style style lang='scss' scoped>
#Card{
  .titleBox {
    display: flex;
    flex-direction: row;
    padding: 2.75rem 2.63rem 0 2.63rem;
    align-items: center;
    background: #fff;

    .title {
      font-size: 1.13rem;
      color: #333;
    }
  }
  .cardBox{
    background-color: #fff;
    padding: 1.75rem 2.62rem;
    margin-bottom: .45rem;
    .header {
      display: flex;
      flex-direction: row;
      justify-content: flex-start;
      align-items: center;
      border-bottom: 0.06rem solid rgba(216, 216, 216, 1);

      .title {
        cursor: pointer;
        font-size: 1.25rem;
        padding: 0.63rem 0.94rem;
        position: relative;
        &.active {
          color: #f0406f;
          position: relative;
          padding: 0.63rem 0.94rem;
          border-bottom: 0.31rem solid rgba(240, 64, 111, 1);
        }
      }
    }
  }
}
</style>
